﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TodoApp.LiveShopAddressDTO;
using TodoApp.UsersModel;
using Volo.Abp.Domain.Repositories;

namespace TodoApp
{
    /// <summary>
    ///  收货地址 
    /// </summary>
    public class AddressService : Volo.Abp.Application.Services.ApplicationService, IAddressService
    {
        private readonly IRepository<LiveShopAddress, int> db;
        public AddressService(IRepository<LiveShopAddress, int> _db) {
            db = _db;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task DeleteAsync(int id)
        {
            await db.DeleteAsync(id);
        }
        /// <summary>
        /// 显示 
        /// </summary>
        /// <returns></returns>
        public async Task<List<LiveShopAddressShowDTO>> GetListAsync()
        {
            return ObjectMapper.Map<List<LiveShopAddress>, List<LiveShopAddressShowDTO>>(await db.GetListAsync());
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<string> InsertAsync(LiveShopAddressAddDTO model)
        {
            await db.InsertAsync(ObjectMapper.Map<LiveShopAddressAddDTO, LiveShopAddress>(model));
            return "添加成功";
        }
    }
}
